// userprog.cc

#include "userprog.h"

// table for lock
Table lockTable(MAX_KERNEL_LOCK);
// table for condition 
Table conditionTable(MAX_KERNEL_CV);
// table for vaddr
//Table vaddrTable(NumPhysPages);
// table for paddr
Table paddrTable(NumPhysPages);

// lock for lock
Lock *lockForLock = new Lock("lock");

// lock for condition 
Lock *lockForCondition = new Lock("condition");

// lock For Deamon
Lock *lockForDeamon = new Lock("deamon");
int isDeamonInit = 0;

// threadSum
int threadSum = 0;
int processId = 0;
int currentMail=0;
Lock *lockForThread = new Lock("threadSum");

// lockForPageTable
//Lock *lockForPageTable = new Lock("pageTable");

// processTable  
ProcessTable processTable[MAX_PROCESS_NUM];
// kernel Lock
KernelLock kernelLock[MAX_KERNEL_LOCK];

// kernel Condition
KernelCV kernelCV[MAX_KERNEL_CV];

Lock *iptLock = new Lock("iptLock");
int nextTlb = 0;
IptEntry ipt[NumPhysPages];
int formerThreadSpaceId = -1;
//define for the swap file

Lock *swapLock = new Lock("swapLock");
Table *swapTable = new Table(SWAPPAGENUM);

Lock *iptFifoLock = new Lock("iptFifoLock"); 
List * iptFifoList = new List();;

//int PFIFO = 1;

